/**

This file is part of MaCI/GIMnet.

MaCI/GIMnet is free software: you can redistribute it and/or modify it 
under the terms of the GNU Lesser General Public License as published 
by the Free Software Foundation, either version 3 of the License, or 
(at your option) any later version.

MaCI/GIMnet is distributed in the hope that it will be useful, but WITHOUT 
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or 
FITNESS FOR A PARTICULAR PURPOSE.  See the GNU Lesser General Public 
License for more details.

You should have received a copy of the GNU Lesser General Public 
License along with GIMnet. (See COPYING.LESSER) If not, see 
<http://www.gnu.org/licenses/>.

**/
#ifndef SHAPES_H
#define SHAPES_H

#include "settings.h"
#include "Primitive.h"
#include "drawutils.h"
#include "OpenGLTextureLoader.hpp"
#include <string>

/****primitive classes****/

class CBox : public CPrimitive
{
  public:
    CBox(dReal sizeX, dReal sizeY, dReal sizeZ, CObject *ParentObject, dSpaceID SpaceID, 
        dBodyID parentBodyID=0, const TMaterial *Material=&DEFAULT_MATERIAL, 
        bool isStatic=false);
    
    ~CBox();
    
    void Draw();
    
    void Draw(std::string const& aTextureName);

 private:
    bool iTextureLoaded;
    GLuint iTextureID;
    
  protected:
    dReal sizeX, sizeY, sizeZ;
};

class CSphere : public CPrimitive
{
  public:
    CSphere(dReal radius, CObject *ParentObject, dSpaceID SpaceID, 
        dBodyID parentBodyID=0, const TMaterial *Material=&DEFAULT_MATERIAL, 
        bool IsStatic=false);
    
    ~CSphere();
    
    void Draw();
    
  protected:
    dReal radius;
};

class CCylinder : public CPrimitive
{
  public:
    CCylinder(dReal radius, dReal length, CObject *ParentObject, dSpaceID SpaceID, 
        dBodyID parentBodyID=0, const TMaterial *Material=&DEFAULT_MATERIAL, 
        bool IsStatic=false);
    
    ~CCylinder();
    
    void Draw();
    
  protected:
    dReal radius, length;
};

class CTrimesh : public CPrimitive
{
  public:

    CTrimesh(float* vertices,int vertexCount,int* indices,int indexCount, CObject *ParentObject, 
          dSpaceID SpaceID, dBodyID parentBodyID=0, 
          const TMaterial *Material=&DEFAULT_MATERIAL, bool isStatic=false);

    ~CTrimesh();

    void Draw();
    
  protected:
    int vertexCount, indexCount, normalCount;
    float* vertices;
    int* indices;
    float* normals;
    
    GLuint displayList;
    
    void calculateNormals();
    
    dHeightfieldDataID hfDataID;
    dTriMeshDataID tmDataID;
};

class CPlane : public CPrimitive
{
  public:
    CPlane(float x1, float y1, float x2, float y2, CObject *ParentObject, dSpaceID SpaceID, 
            const TMaterial *Material=&DEFAULT_MATERIAL);
    
    ~CPlane();
    
    void Draw();
    
  protected:
    float x1, y1, x2, y2;
};

class CTexturedPlane : public CPrimitive
{
  public:
    CTexturedPlane(float x1, float y1, float x2, float y2, CObject *ParentObject, dSpaceID SpaceID, 
                   const TMaterial *Material=&DEFAULT_MATERIAL);
    
    ~CTexturedPlane();
    
    void LoadTexture(std::string aTextureName);

    void Draw();
    
  protected:
    float x1, y1, x2, y2;
    
 private:
    bool iTextureLoaded;
    GLuint iTextureID;

};

#endif
